package JDK11提供的更方便的IO;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

public class Test {
    public static void main(String[] args) throws IOException {
        Files.writeString(Path.of("java新特性/JDK11提供的更方便的IO"), "java 学习java 学习java 学习");

        //Charset.defaultCharset()
        String s = Files.readString(Path.of("java新特性/JDK11提供的更方便的IO"), StandardCharsets.UTF_8);
        //System.out.println(s);

        try {
            InputStream is = new FileInputStream("java新特性/JDK11提供的更方便的IO");
            byte[] bytes = new byte[10];
            int len = 0;
            while ((len = is.read(bytes, 0, bytes.length)) != -1) {
                for (int i = 0; i < len; i++) {
                    System.out.print(bytes[i] + "\t");
                }
                System.out.println();

            }
/*            int read = is.read(bytes, 0, bytes.length);
            System.out.println(read);*/
        } catch (Exception e) {

        }
    }
}
